package com.monitor.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpAdvertisementCheckMapper;
import com.monitor.entity.ErpAdvertisementCheck;
import com.monitor.service.ErpAdvertisementCheckService;
import com.monitor.util.IDUtils;
import com.monitor.util.Result;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 广告待审核表 服务实现类
 * </p>
 *
 * @author LX
 * @since 2018-09-25
 */
@Service
@Transactional
public class ErpAdvertisementCheckServiceImpl extends ServiceImpl<ErpAdvertisementCheckMapper, ErpAdvertisementCheck> implements ErpAdvertisementCheckService {
	@Resource
	private ErpAdvertisementCheckMapper erpAdvertisementCheckMapper;

	@Override
	public Result<String> getCheckNumber() {
		// TODO Auto-generated method stub
		String id="GGHZ"+IDUtils.genOrderId();
		List<ErpAdvertisementCheck> list=erpAdvertisementCheckMapper.selectList(new EntityWrapper<ErpAdvertisementCheck>().like("check_number", id).orderBy("id", false));
		if(list.size()>0) {
			ErpAdvertisementCheck check=list.get(0);
    		String str=check.getCheckNumber().substring(12, check.getCheckNumber().length());
    		str=IDUtils.addOne(str);
    		id+=str;
    	}else {
    		id+="00001";
    	}
		return new Result<String>(id, 1);
	}
	
	
}
